import request from '@/utils/request'
import { setToken } from '@/utils/auth'
import axios from 'axios'

export function login(data) {
  return request({
    // url: '/api/public/manager/login',
    url: `/api/login?username=${data.username}&password=${data.password}`,
    method: 'post'
    // data
  })
}

export function logoff() {
  return request({
    // url: '/api/public/manager/logoff',
    url: '/api/logout',
    method: 'post'
  })
}

export const getUserLoginInfo = () => {
  return request.get('/api/mgr/admin/info')
}

export const refreshToken = () => {
  return request.post('/api/mgr/admin/refresh-token').then(token => {
    setToken(token)
  })
}

export function getCaptchaCode() {
  return axios.get('/api/imageCaptcha/generate', {
    responseType: "blob",
  })
}

export function verificationCaptcha(captcha) {
  return request.post(`/api/imageCaptcha/captcha?captcha=${captcha}`)
}
